Skip to content

test(e2e): cover trusted and untrusted PKI chains - #220

Open
tzprograms wants to merge 1 commit into
sigstore:mainfrom
tzprograms:test/pki-validation-e2e
Open

tzprograms wants to merge 1 commit into
sigstore:mainfrom
tzprograms:test/pki-validation-e2e

Conversation

@tzprograms

Copy link
Copy Markdown
Contributor

Summary

Add Kind E2E coverage for PKI certificate-chain validation through the real validation agent.

  • Add public signed-model and certificate fixtures, with their provenance documented.
  • Deliver the fixtures to test nodes through the existing test-model image and model-data DaemonSet.
  • Add a PKI-specific Pod template and fixture mount without changing shared Pod defaults.
  • Verify that a trusted certificate chain succeeds and that trusting an unrelated CA fails with an unknown authority error.
  • Check the validation agent’s injected arguments, exit status, and logs so the rejection case proves the verifier ran.
  • Delete each Pod before its ModelValidation resource during cleanup.

Testing:

  • Full local three-node Kind E2E suite: 18 passed, 0 failed, pending, or skipped (362.7s).
  • go vet ./test/... passed.
  • E2E package compilation and changed-code lint passed.
  • PKI test-model image build passed.
  • The suite logged the existing metrics-Pod teardown timeout warning in AfterSuite; the specs passed.
  • Hosted CI has not run on this branch.

Release Note

NONE

Documentation

No documentation update is required; this test-only change adds no user-facing behavior.

PKI verification lacked Kind regression coverage. Exercise a trusted
certificate chain and an unrelated trust anchor through the real agent,
using committed public fixtures and the existing E2E templates.

Signed-off-by: Tejas Soham <tejassoham05@gmail.com>
g.Expect(utils.KubectlGetJSON("pod", podName, webhookTestNamespace, &pod)).To(Succeed())
g.Expect(pod.Status.Phase).To(Equal(corev1.PodRunning))
g.Expect(pod.Status.InitContainerStatuses).ToNot(BeEmpty())
initStatus := pod.Status.InitContainerStatuses[0]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The InitContainerStatuses[0] index assumes the validation container is first, but the webhook appends it to the end of InitContainers (internal/webhooks/pod_webhook.go:166) — so this only holds while the pod template has zero other init containers. If someone adds one, the trusted test would read the wrong container's exit code 0 and pass vacuously. Could we select the status by name, like the injection check a few lines up already does? (There may be enough shared shape here for a small expectValidationResult(podName, wantExitZero, logSubstring) helper covering both specs — it would also dedupe the copy in validation_test.go.)

mkdir -p /host-data /host-keys /host-fixtures
cp -r /data/* /host-data/
cp -r /keys/* /host-keys/
cp -r /fixtures/* /host-fixtures/

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The cp -r /fixtures/* /host-fixtures/ runs without set -e, so if the node has a stale model-validation-test-model:latest loaded (with imagePullPolicy: Never it is never re-pulled), the cp fails silently, the DaemonSet still reports ready, and the failure surfaces as a 90s timeout in the PKI tests with no hint of the real cause. Adding set -e (or a [ -d /fixtures ] || exit 1 guard) would crashloop the DaemonSet and fail setup immediately with the actual error.

crData := utils.CRTemplateData{ModelName: modelName, Namespace: webhookTestNamespace, KeyPath: caPath}
podData := pkiPodData(podName, modelName)
// Delete the pod before its ModelValidation so the webhook can still resolve it.
DeferCleanup(func() {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The two Expects are chained in one cleanup func, so if the pod delete fails or times out (it carries the ModelValidation finalizer, so it depends on a live controller), the CR delete never runs and the pki ModelValidation leaks into the specs that run after this file. Registering them as two separate DeferCleanup calls — or tolerating/logging the pod error before deleting the CR — keeps teardown isolated.


By("verifying the init container logs show the CA was not trusted")
Eventually(func(g Gomega) {
output, err := utils.Run(exec.Command("kubectl", "logs", podName, "-n", webhookTestNamespace,

@sampras343 sampras343 Dec 2, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This ~15-line block (fetch pod JSON → check phase → init container exit code → kubectl logs substring) is now in three places: here twice and in validation_test.go:84-91. Any change to log retrieval or status checking has to be made three times. One expectValidationResult(podName, wantExitZero, logSubstring) helper would collapse all of them — and fix the by-index lookup at the same time.

Note: AI Assisted Review Comment

@sampras343 sampras343 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor changes needed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants